Crate stylus_proc

source ·
Expand description

Procedural macros for The Stylus SDK.

You can import these via

use stylus_sdk::prelude::*;

For a guided exploration of the features, please see the comprehensive Feature Overview.

Macros§

  • Facilitates calls to other contracts.
  • The types in #[solidity_storage] are laid out in the EVM state trie exactly as they are in Solidity. This means that the fields of a struct definition will map to the same storage slots as they would in EVM programming languages. Hence, it is often nice to define types using Solidity syntax, which makes this guarantee easier to see.

Attribute Macros§

  • Defines the entrypoint, which is where Stylus execution begins. Without it the contract will fail to pass cargo stylus check. Most commonly this macro is used to annotate the top level storage struct.
  • Just as with storage, Stylus SDK methods are Solidity ABI-equivalent. This means that contracts written in different programming languages are fully interoperable. You can even automatically export your Rust contract as a Solidity interface so that others can add it to their Solidity projects.
  • Allows a Rust struct to be used in persistent storage.

Derive Macros§

  • Some StorageType values implement Erase, which provides an erase() method for clearing state. The Stylus SDK implements Erase for all primitives, and for vectors of primitives, but not for maps. This is because a Solidity mapping does not provide iteration, and so it’s generally impossible to know which slots to clear.
  • Allows an error enum to be used in method signatures.